{% extends "admin/base.html" %}

{% block title %}{% if action == 'add' %}添加标签{% else %}编辑标签{% endif %}{% endblock %}

{% block page_title %}{% if action == 'add' %}添加标签{% else %}编辑标签{% endif %}{% endblock %}

{% block content %}
<div class="card">
    <div class="card-header">
        <h2>{% if action == 'add' %}添加新标签{% else %}编辑标签{% endif %}</h2>
    </div>
    <div class="card-body">
        {% if error %}
        <div class="alert alert-danger">
            {{ error }}
        </div>
        {% endif %}
        
        <form method="post" action="/admin/tags/save">
            {% if tag %}
            <input type="hidden" name="id" value="{{ tag.id }}">
            {% endif %}
            
            <div class="form-group">
                <label for="name">标签名称 <span style="color: #e74c3c;">*</span></label>
                <input type="text" id="name" name="name" value="{% if tag %}{{ tag.name }}{% endif %}" required>
            </div>
            
            <div class="form-check">
                <input type="checkbox" id="is_active" name="is_active" {% if not tag or tag.status %}checked{% endif %}>
                <label for="is_active">启用</label>
            </div>
            
            <div style="margin-top: 30px;">
                <button type="submit" class="btn btn-primary" style="margin-right: 10px;">保存</button>
                <a href="/admin/tags" class="btn btn-secondary">取消</a>
            </div>
        </form>
    </div>
</div>
{% endblock %}